/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package music.emotion.engine.rules;

import java.io.Serializable;
import java.util.ArrayList;
import music.emotion.engine.facts.Facts;

/**
 *
 * @author Morian
 */
public class Rule implements Serializable{
    // Giả thuyết được biểu diễn dưới dạng GT1 ^ GT2 ... ^ GTn -> KL

    public ArrayList<Facts> GT;
    public ArrayList<Facts> KL;
    public boolean removed = false;

    public Rule(ArrayList<Facts> gt, ArrayList<Facts> kl) {
        GT = gt;
        KL = kl;
//        for(Facts f: gt){
//            System.out.print(f.name);
//        }
//        System.out.println(kl.get(0));
    }

    public boolean match(ArrayList<Facts> asset) {
        int test = 0;
        for (int i = 0; i < this.GT.size(); i++) {
            for(int j = 0 ; j< asset.size();j++){
                if(GT.get(i).compareTo(asset.get(j))==0 ){
                    test++;
                    break;
                }
            }
        }
        if(test== GT.size()){
            return true;
        }else{
            return false;
        }
    }
    
    @Override
    public String toString() {
        String str = this.GT.toString();
        str += ":" + this.KL.toString();
        return str;
    }
}
